package com.zlsy.springbootdemo.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @author zhouliang
 * @date 2020/6/3 10:32
 */
public class AgeUtil {

    private static final List<Integer> list = new ArrayList<>();
    private static final Random RANDOM = new Random();

    static {
        for (int i = 1; i < 101; i++) {
            list.add(i);
        }
    }

    public static int getAgeByRandom() {
        int index = RANDOM.nextInt(list.size() - 1);
        int[] ageArray = list.stream().mapToInt(Integer::valueOf).toArray();
        return ageArray[index];
    }
}
